<%@page import="service.MovieService"%>
<%@page import="entity.Pagination"%>
<%@page import="entity.Movie"%>
<%@page import="dao.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("gbk");
	String search = request.getParameter("search");
	MovieService ms = new MovieService();
	ArrayList<Movie> cs = ms.find(search);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>电影</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 
	 <link href="css/bootstrap.css" rel="stylesheet">
  </head>
  <script src="js/jquery2.2.3.js"></script>
  <script src="js/bootstrap.js"></script>
  <body>
    <nav class="navbar navbar-default" role="navigation">
   <div class="navbar-header">
      <a class="navbar-brand" href="index.jsp">电影网</a>
   </div>
    <div>
      <ul class="nav navbar-nav">
         <li><a href="movie.jsp">所有电影</a></li>
         <li><a href="inform.jsp">我的电影</a></li> 
      </ul>
        <% if(session.getAttribute("id")==null){ %>
      <ul class="nav navbar-nav navbar-right">
         <li><a href="login.jsp">登录</a></li>
         <li><a href="register.jsp">注册</a></li>   
      </ul>
      <%  }  else {
String uid = session.getAttribute("id").toString();
UserDao userdao = new UserDao();
String username = userdao.findById(uid);%>
      	 <ul class="nav navbar-nav navbar-right">
         <li><a>欢迎你,<%=username %></a></li>
         <li><a href="loginout.jsp">退出</a></li>   
      </ul>
      <% } %>
</div>
</nav>
  
  
  <div class="container-fluid">
	<div class="row-fluid">
		<h1>查询结果</h1>
			<%
				for(Movie c:cs){
			%>
			<div class="col-sm-12">
			   <div class="thumbnail" style="border-color:gray;">
 	 					<img src="<%=c.getPicture() %>"  title="" style="float:left;padding-top:20px;padding-left: 20px;height: 251px">
 	 				
 	 					<div class="caption" style="margin-left: 200px;margin-bottom: 190px"> 	 					
            				<h2><%=c.getName() %><span class="label label-info" style="float:right">￥<%=c.getPrice() %></span></h2>
            				<div style="float:left;margin-top:20px">
            				<p>导演：<%=c.getDirector() %></p>
            				<p>主演：<%=c.getActor() %></p>
            				<p>类型：<%=c.getType() %></p>
            				<p>时长：<%=c.getLength() %></p>
            				 
            				<button type="button" class="btn btn-primary" onclick="window.location.href='purchase.jsp?id=<%=c.getMid()%>'">购买</button>
            				</div>            				
            			</div> 
            								
 	 				</div>
			</div>
			<%
				}
			%>
<%-- 	<div class="col-sm-9">
	<ul class="pagination pull-left">
	<li><a href="movie.jsp?pageIndex=1">首页</a></li>
	<li><a href="movie.jsp?pageIndex=<%=pagination.getCurrentPage()-1%>">上页</a></li>
	<li><a  href="movie.jsp?pageIndex=<%=pagination.getCurrentPage()+1%>">下页</a></li>
	<li> <a href="movie.jsp?pageIndex=<%=pagination.getTotalPage()%>" > 末页</a> </li>
	</ul>
	<p style="padding-top:24px;margin-left:240px">共<%=pagination.getTotalRow()%>条记录，当前第<%=pagination.getCurrentPage()%>页/共<%=pagination.getTotalPage()%>页 </p>
	</div>
--%>
</div>
  	
 </div>
</body>
</html>
